import { ApiProperty } from "@nestjs/swagger";
import { IsArray, IsBoolean, IsEmail, IsMobilePhone, IsNumber, IsOptional, IsString, Length } from "class-validator";

export enum GenderEnum {
  UNKNOWN = 0,
  MALE = 1,
  FEMALE = 2
}
export class CreateUserDto {
  @ApiProperty({ 
    description: '用户名',
    example: 'admin'
  })
  @IsString()
  @Length(4, 20, { message: '用户名长度必须在4-20个字符之间' })
  username: string;

  @ApiProperty({ 
    description: '密码',
    example: '123456'
  })
  @IsString()
  @Length(6, 20, { message: '密码长度必须在6-20个字符之间' })
  password: string;

  @ApiProperty({ description: '昵称' })
  nickname?: string;

  @ApiProperty({ 
    description: '性别(0-未知 1-男 2-女)',
    enum: GenderEnum,
    default: GenderEnum.UNKNOWN,
    required: false
  })
  @ApiProperty({ description: '性别' })
  gender?: number;

  @ApiProperty({ 
    description: '所属部门id',
    required: false
  })
  @IsOptional()
  dept_id?: number;

  @ApiProperty({ 
    description: '手机号',
    required: false,
    example: '13800138000'
  })
  @IsOptional()
  @IsMobilePhone('zh-CN', {}, { message: '请输入有效的手机号码' })
  mobile?: string;

  @ApiProperty({ 
    description: '邮箱',
    required: false,
    example: 'test@example.com'
  })
  @IsOptional()
  @IsEmail({}, { message: '请输入有效的邮箱地址' })
  email?: string;

  @ApiProperty({ 
    description: '状态',
    default: true,
    required: false
  })
  @IsOptional()
  @IsBoolean()
  status?: boolean;

  @ApiProperty({ 
    description: '角色ID数组',
    type: [String],
    required: false,
    example: [1, 2]
  })
  @IsOptional()
  @IsArray()
  roleIds?: string[];
}
